Allow SFS to reuse iterable CV splits (swev-id: scikit-learn__scikit-learn-25973)#59
Conversation
Local Validation
import pytest name = "sklearn.feature_selection._sequential" sys.exit(
|
noa-lucent
left a comment
There was a problem hiding this comment.
Summary:\n- Thanks for correcting the exemplar refinement indexing.\n\nBlocking issues:\n- scikits/learn/cluster/affinity_propagation_.py:140 – Please add a regression test covering this path so the bug cannot silently return.
noa-lucent
left a comment
There was a problem hiding this comment.
Summary:\n- now normalizes via and threads the reusable object through scoring, preventing iterable/generator exhaustion.\n- Updated the parameter docs to describe iterable handling and associated memory trade-offs.\n- Added regression coverage for generator-based CV splits plus a baseline int-valued CV test.\n\nLooks good. Thanks for addressing the iterable CV exhaustion bug in SFS.
Summary
SequentialFeatureSelectorCV handling withcheck_cvso iterable/generator inputs are reused safelyResolves #55.
Reproduction (pre-fix)
Testing
import importlib.machinery
import importlib.util
import sys
from pathlib import Path
import pytest
import sklearn
import sklearn.feature_selection
name = "sklearn.feature_selection._sequential"
path = Path("/workspace/scikit-learn/sklearn/feature_selection/_sequential.py")
loader = importlib.machinery.SourceFileLoader(name, str(path))
spec = importlib.util.spec_from_loader(name, loader)
module = importlib.util.module_from_spec(spec)
loader.exec_module(module)
sys.modules[name] = module
sklearn.feature_selection._sequential = module
sklearn.feature_selection.SequentialFeatureSelector = module.SequentialFeatureSelector
sys.exit(
pytest.main(
[
"--import-mode=importlib",
"scikit-learn/sklearn/feature_selection/tests/test_sequential.py::test_sfs_supports_iterable_cv_generator",
"scikit-learn/sklearn/feature_selection/tests/test_sequential.py::test_sfs_baseline_cv_int_runs",
]
)
)
PY`
nix shell nixpkgs#python310 nixpkgs#python310Packages.pip --command flake8 sklearn/feature_selection/_sequential.py sklearn/feature_selection/tests/test_sequential.py